<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<html>

 <head>
    
    <title>多PI入库管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
  	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/batchIn";
		var basic_WUrl="logic/batchIn";
		var basic_Title="多PI入库管理";
		var show_Width=950;
		var show_Hight=400;
		var user='${user.name}';
		var grid=null;
		$(function(){
			grid = $("#table1").ligerGrid({
		        columns: [
		                  { display: '入库单号', name: 'zd001Code', width: 150},
		                  { display: '入库仓库', name: 'zd003WhName', width: 100},
		                  { display: '单据状态', name: 'zd010Stauts', width: 100,
		                	render : function(item){
		                		if (item.zd010Stauts == 'BATCHIN_SAVE'){
		                			return "草稿";
		                		}else if (item.zd010Stauts == 'BATCHIN_SUBMIT'){
		                			return "审批中";
		                		}else if (item.zd010Stauts == 'BATCHIN_END'){
		                			return "完成";
		                		}else if (item.zd010Stauts == 'BATCHIN_BACK'){
		                			return "驳回";
		                		}else{
		                			return item.zd010Stauts;
		                		}
		                	}  
		                  },
		                  { display: '入库时间', name: 'zd004InDate', width: 120,
		                	  render: function (item){
		                		  var cdate=new Date(item.zd004InDate);
		                		  return formatDate(cdate,"yyyy-MM-dd");
		                	  }
		                  },
		                  { display: '送货单号', name: 'zd002InNumber', width: 150},
		                  { display: '供应商', name: 'zd007SupplierName', width: 100},
		                  { display: '制单人', name: 'zd006MakerName',width: 100 }
		                  ],  usePager: true,pageSize:15,
		                      url : basic_Url+"/list.do",
		                      width: '100%', height: '95%',pageSizeOptions :[15,25,35], checkbox: true,rownumbers:true,
		                      onDblClickRow : function (data, rowindex, rowobj){
		                          edit(data);
		                       }
		                  });
			$("#pageloading").hide();
		});

		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows =manager.getSelectedRows();
			var bol = false;
			if (rows==null || 0 == rows.length){
					$.dialog.alert('请选择需要操作删除的行！');
					return;
			}
			for(var i=0;i<rows.length;i++){
			 	if (rows[i].zd006MakerName != user){
			 		bol = true;
				}
			}
			if(bol){
				$.dialog.alert('请选择自己创建的草稿单据进行删除操作!');
				return;
			}else{
				bol = false;
				for(var i=0;i<rows.length;i++){
				 	if (!(rows[i].zd010Stauts=='BATCHIN_SAVE'||rows[i].zd003BillStatus=='BATCHIN_BACK')){
				 		bol = true;
					}
				}
				if(bol){
					$.dialog.alert('非草稿状态或退回的单据不能删除!');
					return;
				}else{
					del();
					bol = false;
				}
			}	
		}
		
		function createSearch(){
			init(1,8,'100,100,100,100,100,100,100,100','20%');
			//第一行的数据
			addCommon(0,0,"lable","入库单号");
			addCommon(0,1,"txtlike","zd001Code");
			addCommon(0,2,"lable","入库仓库：");
			addCommon(0,3,"selectEnum","zd003WhCode","<option></option><c:forEach var="s" items="${wh}"><option value='${s.zd002Code}'>${s.zd003Name}</option></c:forEach>");
			addCommon(0,4,"lable","制单人");
			addCommon(0,5,"txtlike","zd006MakerName");
			addCommon(0,6,"lable","单据状态：");
			addCommon(0,7,"selectEnum","zd010Stauts","<option></option><option value='BATCHIN_SAVE'>草稿</option>"+
					"<option value='BATCHIN_SUBMIT'>审批中</option><option value='BATCHIN_END'>完成</option><option value='BATCHIN_BACK'>驳回</option>");
			init(1,8,'100,100,100,100,100,100,100,100','20%');
			addCommon(1,0,"lable","送货单号");
			addCommon(1,1,"txtlike","zd002InNumber");
			addCommon(1,2,"lable","供应商");
			addCommon(1,3,"txtlike","zd007SupplierName");
			addCommon(1,4,"lable","入库开始时间");
			addCommon(1,5,"datestart","zd004InDate");
			addCommon(1,6,"lable","入库结束时间");
			addCommon(1,7,"dateend","zd004InDate");
		}
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
	  function excelExport(){
		   	var filtersStr = generateCondition();
		   	var path = "${ctx}/excel/batchInExcel.do?filters="+filtersStr+"&_search=true";
			window.open(path,"_blank");
	  }
	</script>
  </head>
<body onload="createSearch()">
   <div id="layout1">
      <div position="top">
          <div class="panelBar">
	           <ul class="toolBar">
		           <li><a class="add" onclick="add()">
		           <span>添加</span></a></li>
				   <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
			             	<li><a class="button" onclick="excelExport()"><span>导出</span></a></li>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
   </div>
 
</body>
</html>